package kr.hkit.powerjava.homework2;

public class Stack {
	@Override
	public String toString() {
		return "Stack [top=" + top + ", size=" + size + ", arritem=" + top
				+ "]";
	}

	private int top;
	private int size;
	private String[] arritem;

	public Stack(int size) {
		this.size = size;
		arritem = new String[size];
		top = -1;
	}

	public void push(String item) {
		
			if (!isFull()) {
				 arritem[++top]=item;
			} else {
				System.err.println("FULL");
			}

		
	}


	public String pop() {
		if (!isEmpty()) {
			return arritem[top--];
		} else {
			return "Empty";
		}


	}

	public boolean isFull() {
		return top==size-1;
	}

	public boolean isEmpty() {

		return top == -1;

	}

	public void prnStack() {
		for (int i = 0; i <= top; i++) {
			System.out.printf("%s\t",arritem[i]);
		}
		System.out.println();
	}
}
